package com.project.geonotes;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.database.CursorJoiner.Result;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.Toast;

public class CategoryDownloadAsyncTask extends AsyncTask<Intent, Void, Void> {
	private AccountManager mAccountManager;
	private Account[] accounts;
	private String uniqueID;
	private WebWrapper mWrapper;
	private Notification mNotification;
	private NotificationManager mNotificationManager;
	private Context mContext;
	public CategoryDownloadAsyncTask(Context mContext, AccountManager manager, Notification not, NotificationManager notMan) {
		mAccountManager = manager;
		mNotification = not;
		mNotificationManager = notMan;
		this.mContext = mContext;
	}

	@Override
	protected Void doInBackground(Intent... arg0) {
		accounts = mAccountManager.getAccountsByType("com.google");
		uniqueID = accounts[0].name;
		Intent intent = arg0[0];
		Bundle extras = intent.getExtras();
		if (extras.getString("action").equals("download")) {
			try {
				mWrapper = new WebWrapper(uniqueID);
			} catch (Exception e) {
	            Toast.makeText(mContext, "Could not connect to the server.  Aborting.", 1000).show();
	            return null;
			}
		} else {
			//parse extras, get info for WebWrapper call and initialize 
		}
		return null;
	}
	

}
